<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="./vue.js"></script>
<script src="./vuex.js"></script>

<body>
  <div id="app">
    <button @click="param">传递参数</button>
    <p>{{ this.$store.state.param }}</p>
  </div>

  <script>
    // let store =  new Vuex.store({
    const store = new Vuex.Store({
      state: {
        param: ""
      },
      mutations: {
        receive(state, param) {
          state.param = param
        }
      },
      actions: {
        param(context) {
          context.commit("receive", "我是传递的参数!")
        }
      }
    })

    const vm = new Vue({
      el: "#app",
      store,
      methods: {
        param() {
          this.$store.dispatch("param")
        }
      }
    })
  </script>
</body>

</html>